package com.usian.controller;


import com.usian.pojo.TbContent;
import com.usian.pojo.TbContentCategory;
import com.usian.service.ContentService;
import com.usian.utils.AdNode;
import com.usian.utils.PageResult;
import com.usian.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ContentController {

    @Autowired
    private ContentService contentService;

    @RequestMapping("selectContentCategoryByParentId")
    List<TbContentCategory> selectContentCategoryByParentId(@RequestParam Long id){
        return contentService.selectContentCategoryByParentId(id);
    }

    @RequestMapping("insertContentCategory")
    Boolean insertContentCategory(@RequestParam Long parentId,@RequestParam String name){
        return contentService.insertContentCategory(parentId,name);
    }

    @RequestMapping("deleteContentCategoryById")
    void deleteContentCategoryById(@RequestParam Long categoryId){

         contentService.deleteContentCategoryById(categoryId);
    }

    @RequestMapping("updateContentCategory")
    Boolean updateContentCategory(@RequestParam Long id, @RequestParam String name){
        return contentService.updateContentCategory(id,name);
    }

    @RequestMapping("selectTbContentAllByCategoryId")
    PageResult selectTbContentAllByCategoryId(@RequestParam Long categoryId){
        return contentService.selectTbContentAllByCategoryId(categoryId);
    }

    @RequestMapping("insertTbContent")
    Boolean insertTbContent(@RequestBody TbContent tbContent){
        return contentService.insertTbContent(tbContent);
    }

    @RequestMapping("deleteContentByIds")
    void deleteContentByIds(Integer[] ids){
        contentService.deleteContentByIds(ids);
    }

    @RequestMapping("selectFrontendContentByAD")
    List<AdNode> selectFrontendContentByAD(){
        return contentService.selectFrontendContentByAD();
    }

}
